package com.cskaoyan.uploadutil;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName: Date2String
 * @Author: WangEnzhao
 * @Description: Date转换为String
 * @CreateTime: 2021/12/18:44:00
 */
public class Date2StringUtil {

    public static String format(Date date, String pattern){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        String result = simpleDateFormat.format(date);
        return result;
    }

    public static String formatWithoutTime(Date date){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy-MM-dd");
        String result = simpleDateFormat.format(date);
        return result;
    }
    public static String formatWithTime(Date date){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
        String result = simpleDateFormat.format(date);
        return result;
    }

}
